#!/usr/bin/env node
var fs = require('fs')
var mustache = require('mustache')
var api = require('../src/api.json')

var methods = []
Object.keys(api).sort().forEach(method=> {
  var params = api[method].join(', ')
  var interpolated = `[\`slack.${method}({${params}})\`](https://api.slack.com/methods/${method})`
  methods.push(interpolated)
})

var tmpl = fs.readFileSync(__dirname + '/../readme.tmpl', { encoding: 'utf8'})
var rendered = mustache.render(tmpl, {methods})

fs.writeFileSync(__dirname + '/../readme.md', rendered)
